package com.easyweb.session;

import com.easyweb.entity.*;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.EntityManager;

@Name("gorevlerList")
public class GorevlerList extends EntityQuery<Gorevler> {

	@In private EntityManager entityManager;
	
	private List<Gorevler> gorevlerListesi=null;
	
	 
	private static final String EJBQL = "select gorevler from Gorevler gorevler";

	private static final String[] RESTRICTIONS = { "lower(gorevler.gorevAdi) like lower(concat(#{gorevlerList.gorevler.gorevAdi},'%'))", };

	private Gorevler gorevler = new Gorevler();

	private String deneme;
	
	public void setGorevler(Gorevler gorevler) {
		this.gorevler = gorevler;
	}

	public GorevlerList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Gorevler getGorevler() {
		return gorevler;
	}

	public void gorevlerListesiOlustur(){
	gorevlerListesi=new ArrayList<Gorevler>();
	gorevlerListesi=entityManager.createNamedQuery("gorevlerTumList").getResultList();
	}
	
	public List<Gorevler> getGorevlerListesi() {
		if (gorevlerListesi==null) gorevlerListesiOlustur();
		return gorevlerListesi;
	}

	public void setGorevlerListesi(List<Gorevler> gorevlerListesi) {
		this.gorevlerListesi = gorevlerListesi;
	}
}
